<template>
	<view class="my-userinfo-containe">
		<!-- 头像区域 -->
		<view class="top-box">
			<image :src="userinfo.avatarUrl" class="avatar"></image>
			<text class="nickname">{{userinfo.nickName}}</text>
		</view>
		<!-- =面版区域 -->
		<view class="panle-list">
			<!-- 第1个面板 -->
			<view class="panle">
				<view class="panle-body">
					<view class="panle-item">
						<text>8</text>
						<text>收藏的店铺</text>
					</view>
					<view class="panle-item">
						<text>14</text>
						<text>收藏的商品</text>
					</view>
					<view class="panle-item">
						<text>18</text>
						<text>收关注的商品</text>
					</view>
					<view class="panle-item">
						<text>84</text>
						<text>足迹</text>
					</view>
				</view>
			</view>
			<!-- 第2个面板 -->
			<view class="panle">
				<view class="panle-title">
					<text>我的订单</text>
				</view>
				<view class="panle-body">
					<view class="panle-item">
						<image src="../../static/my-icons/icon1.png" class="icon" ></image>
						<text>待付款</text>
					</view>
					<view class="panle-item">
						<image src="../../static/my-icons/icon2.png" class="icon"></image>
						<text>待收货</text>
					</view>
					<view class="panle-item">
						<image src="../../static/my-icons/icon3.png" class="icon"></image>
						<text>退货/退款</text>
					</view>
					<view class="panle-item">
						<image src="../../static/my-icons/icon4.png" class="icon"></image>
						<text>全部订单</text>
					</view>
				</view>
				
			</view>
			<!-- 第3个面板 -->
			<view class="panle">
				<view class="panle-list-item">
					<text>收货地址</text>
					<uni-icons type="arrowright" size="15"></uni-icons>
				</view>
				<view class="panle-list-item">
					<text>联系客服</text>
					<uni-icons type="arrowright" size="15"></uni-icons>
				</view>
				<view class="panle-list-item" @click="logout">
					<text>退出登录</text>
					<uni-icons type="arrowright" size="15"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState,mapMutations} from 'vuex'
	export default {
		name:"my-userinfo",
		data() {
			return {
				
			};
		},
		onLoad(){
			console.log(this.userinfo);
		},
		methods:{
			...mapMutations('m_user',['updateAddress','updateUserInfo','updateToken']),
			async logout() {
				const [err,succ] = await uni.showModal({
					title:'提示',
					content:'确认退出么'
				}).catch(err => err)
				if(succ && succ.confirm) {
					// 用户点击了确认
					this.updateAddress({})
					this.updateToken('')
					this.updateUserInfo({})
				}
			}
		},
		computed:{
			...mapState('m_user',['userinfo'])
		}
	}
</script>

<style lang="scss">
.my-userinfo-containe {
	height: 100%;
	background-color: #f4f4f4;

	.top-box{
		height: 400rpx;
		background-color: #C00000;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		.avatar{
			width: 90px;
			height: 90px;
			border-radius: 45px;
			border: 2px solid #fff;
		}
		.nickname{
			font-size: 18px;
			margin-top: 10px;
			font-weight: bold;
			color: #fff;
		}
	}
	.panle-list {
		position: relative;
		padding:0 10px;
		top: -10px;
		.panle{
			padding: 10px 10px;
			background-color: white;
			border-radius: 10px;
			margin-bottom: 8px;
			.panle-list-item {
				height: 40px;
				line-height: 40px;
				display: flex;
				justify-content: space-between;
				margin-bottom: 3px;
				font-size: 15px;
			}
			.panle-title{
				line-height: 45px;
				padding-left: 10px;
				font-size: 15px;
				border-bottom: 1px solid #f4f4f4;
			}
			.panle-body{
				display: flex;
				justify-content: space-around;
				.panle-item{
					display: flex;
					flex-direction: column;
					align-items: center;
					font-size: 14px;				
				}
				.icon {
					display: inline-block;
					width: 35px;
					height: 35px;
				}
			}
		}
	}
	
}
</style>